package com.dzsw.thread;

/**
 * @version 1.0
 * @author sunz
 * @CreateTime 2021-04-20-11:19
 */
public class JoinMain {

    public static void main(String[] args) throws Exception{
        System.out.println(Thread.currentThread().getName() + " start.");
        Thread t = new Thread(()-> {
            System.out.println(Thread.currentThread().getName() + " start.");
            try {
                Thread.sleep(3 * 1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName() + " end.");
        });
        t.start();
        System.out.println(1);
        t.join();
        System.out.println(2);
        System.out.println(Thread.currentThread().getName() + " end.");
    }
}
